package com.chujiekeji.test.fragment.friend;
import android.content.Intent;
import com.chujiekeji.test.activity.chat.ChatActivity;
import com.chujiekeji.test.adapter.BaseRecyclerAdapter;
import com.chujiekeji.test.adapter.friend.PengYouAdapter;
import com.chujiekeji.test.api.ChujieApi;
import com.chujiekeji.test.bean.PageBean;
import com.chujiekeji.test.bean.ResultBean;
import com.chujiekeji.test.bean.friend.PengYou;
import com.chujiekeji.test.fragment.base.BaseRecyclerViewFragment;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
public class PengYouFragment extends BaseRecyclerViewFragment<PengYou> implements BaseRecyclerAdapter.OnItemClickListener {

	@Override
	protected BaseRecyclerAdapter<PengYou> getRecyclerAdapter() {
		return new PengYouAdapter(getContext(),BaseRecyclerAdapter.ONLY_FOOTER);
	}

	@Override
	protected Type getType() {
		return new TypeToken<ResultBean<PageBean<PengYou>>>() {
		}.getType();
	}
	@Override
	protected void requestData() {
		super.requestData();
		ChujieApi.fetchPengYou(isRefreshing ? 1 : (mBean.getNextPage()==null?1:mBean.getNextPage()),20,2,mHandler);
	}
	@Override
	public void onItemClick(int position, long itemId) {
		PengYou pengYou = mBean.getItems().get(position);
		Intent intent = new Intent(getContext(), ChatActivity.class);
		intent.putExtra("nickName",pengYou.getNickName());
		intent.putExtra("helpNum",""+pengYou.getFriendHelpNum());
		startActivity(intent);
	}
}
